﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Frame.Lib.Core.Tree;


namespace Jzy.Model.Project
{
    public partial class PrjTaskInfo:TreeInfo
    {
        //排序,创建人和ID一样,修改时不修改
        public override string GetTableName()
        {
            return "PrjTask";
        }
        public override string GetInsertSql()
        {
            return "insert into PrjTask ( [ID], [Name], [PrjID], [UpperID], [Depth], [Path], [Orders], [UserIDs], [UserNames], [StartTime], [EndTime], [TimeLimit], [IsPrediction], [Percent], [IsMilestone], [Remark], [CreatorID], [CreatorName], [Workload], [CalendarID]) values ( @ID, @Name, @PrjID, @UpperID, @Depth, @Path, @Orders, @UserIDs, @UserNames, @StartTime, @EndTime, @TimeLimit, @IsPrediction, @Percent, @IsMilestone, @Remark, @CreatorID, @CreatorName, @Workload, @CalendarID)";
        }
        public override string GetUpdateSql()
        {
            return "update PrjTask set  [ID] = @ID, [Name] = @Name, [PrjID] = @PrjID, [UpperID] = @UpperID, [Depth] = @Depth, [Path] = @Path, [Orders] = @Orders, [UserIDs] = @UserIDs, [UserNames] = @UserNames, [StartTime] = @StartTime, [EndTime] = @EndTime, [TimeLimit] = @TimeLimit, [IsPrediction] = @IsPrediction, [Percent] = @Percent, [IsMilestone] = @IsMilestone, [Remark] = @Remark, [CreatorID] = @CreatorID, [CreatorName] = @CreatorName, [Workload] = @Workload, [CalendarID] = @CalendarID where ID = @ID";
        }

        public PrjTaskInfo() { }
        
        public Int32 PrjID
        {
            get;
            set;
        }
       
        public String UserIDs
        {
            get;
            set;
        }
        public String UserNames
        {
            get;
            set;
        }
        public DateTime StartTime
        {
            get;
            set;
        }
        public DateTime EndTime
        {
            get;
            set;
        }
        public Double TimeLimit
        {
            get;
            set;
        }
        public Boolean IsPrediction
        {
            get;
            set;
        }
        public Int32 Percent
        {
            get;
            set;
        }
        public Boolean IsMilestone
        {
            get;
            set;
        }
        public String Remark
        {
            get;
            set;
        }
        public Int32 CreatorID
        {
            get;
            set;
        }
        public String CreatorName
        {
            get;
            set;
        }
        public Int32 Workload
        {
            get;
            set;
        }

        public int? CalendarID
        {
            get;
            set;
        }

        public override void SetValue(string key, object value)
        {
            key = key.ToLower();
            switch (key)
            {
                case "id":
                    this.ID = (Int32)value;
                    break;
                case "name":
                    this.Name = (String)value;
                    break;
                case "prjid":
                    this.PrjID = (Int32)value;
                    break;
                case "upperid":
                    this.UpperID = (Int32)value;
                    break;
                case "depth":
                    this.Depth = (Int32)value;
                    break;
                case "path":
                    this.Path = (String)value;
                    break;
                case "orders":
                    this.Orders = (Int32)value;
                    break;
                case "userids":
                    this.UserIDs = (String)value;
                    break;
                case "usernames":
                    this.UserNames = (String)value;
                    break;
                case "starttime":
                    this.StartTime = (DateTime)value;
                    break;
                case "endtime":
                    this.EndTime = (DateTime)value;
                    break;
                case "timelimit":
                    this.TimeLimit = (Double)value;
                    break;
                case "isprediction":
                    this.IsPrediction = (Boolean)value;
                    break;
                case "percent":
                    this.Percent = (Int32)value;
                    break;
                case "ismilestone":
                    this.IsMilestone = (Boolean)value;
                    break;
                case "remark":
                    this.Remark = (String)value;
                    break;
                case "creatorid":
                    this.CreatorID = (Int32)value;
                    break;
                case "creatorname":
                    this.CreatorName = (String)value;
                    break;
                case "workload":
                    this.Workload = (Int32)value;
                    break;
                case "calendarid":
                    this.CalendarID = (Int32?)value;
                    break;
            }
        }
        public override object GetValue(string key)
        {
            key = key.ToLower();
            switch (key)
            {
                case "id":
                    return this.ID;
                case "name":
                    return this.Name;
                case "prjid":
                    return this.PrjID;
                case "upperid":
                    return this.UpperID;
                case "depth":
                    return this.Depth;
                case "path":
                    return this.Path;
                case "orders":
                    return this.Orders;
                case "userids":
                    return this.UserIDs;
                case "usernames":
                    return this.UserNames;
                case "starttime":
                    return this.StartTime;
                case "endtime":
                    return this.EndTime;
                case "timelimit":
                    return this.TimeLimit;
                case "isprediction":
                    return this.IsPrediction;
                case "percent":
                    return this.Percent;
                case "ismilestone":
                    return this.IsMilestone;
                case "remark":
                    return this.Remark;
                case "creatorid":
                    return this.CreatorID;
                case "creatorname":
                    return this.CreatorName;
                case "workload":
                    return this.Workload;
                case "calendarid":
                    return this.CalendarID;
                default:
                    return null;
            }
        }



        public PrjTaskInfo Clone()
        {
            PrjTaskInfo info = new PrjTaskInfo();
            Type type = info.GetType();
            foreach (PropertyInfo property in type.GetProperties())
            {
                property.SetValue(info, this.GetType().GetProperty(property.Name).GetValue(this, null), null);
            }
            return info;
        }
    }

}
